var KOC = require("koc.common.utils");
var Iconv = require('iconv-lite');

module.exports = {
    Send: function (Phone, VerifyCode, News, callback) {
        if (News) {
            News = encodeURI(Iconv.encode(News, 'GB2312'));
        }
        var options = {
            uri: "http://211.147.239.62:9050/cgi-bin/sendsms?username=bjxy@bjxy&password=WoAiXiYou@2015&to=" + Phone + "&text=" + VerifyCode + News,
            // headers: {
            //     'content-type': 'text/html; charset=UTF-8'
            // },
            method: "GET"
        };
        KOC.Request(options, function (error, response, result) {
            if (error) {
                callback(KOC.ReturnValue.New({
                    hasError: true,
                    message: err.message
                }));
                return;
            }
            if (result !== "0") {
                callback(KOC.ReturnValue.New({
                    hasError: true,
                    message: "接口返回错误：" + result
                }));
                return;
            }
            callback(KOC.ReturnValue.New());
        });
    }
};